
package com.example.attendancesystem.Listen;


import com.example.attendancesystem.Service.LoginAndRegisterService;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;


@Component
public class MySessionAttributeListen implements HttpSessionAttributeListener {
    @Autowired
    private LoginAndRegisterService loginAndRegisterService;

    @SneakyThrows
    public void attributeAdded(HttpSessionBindingEvent se) {

    }

    //移除session
    public void attributeRemoved(HttpSessionBindingEvent se) {
        /*System.out.println("session移除");
        Login login = (Login) se.getSession().getServletContext().getAttribute("login");
        int number = login.getNumber();
        System.out.println(number);
        HttpSession session = (HttpSession) se.getSession().getServletContext();
        loginAndRegisterService.moveNumberCount(number,session);*/
    }

    //替代session
    public void attributeReplaced(HttpSessionBindingEvent se) {
    }
}

